﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Random r = new Random();
            //    1、生成一个随机整型数组，长度是10，内容是1~10，数组内容不重复。
            int[] arr = new int[10];

            Random ran = new Random();

            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = ran.Next(10)+1;
                for (int j = 0; j < i; j++)
                {
                    if (arr[i] == arr[j])
                    {
                        arr[i] = ran.Next(10) + 1;
                        j = -1;
                    }
                }
                Console.Write(arr[i] + " ");
            }
            Console.WriteLine();
                Console.WriteLine("====================================");
            //2、生成0 - 5之间的随机小数，保留两位小数。

            for (int i = 0; i < 51; i++)
            {
                Console.WriteLine(Math.Floor((r.NextDouble() * (r.Next(5) + 1)) * 100) / 100.0);

            }
            Console.WriteLine("================================");
            //3、生成4 - 7之间的随机小数，保留两位小数。


            for (int i = 0; i < 51; i++)
            {
                double a = (r.NextDouble() + (r.Next(4) + 4));
                string b = a.ToString();
                Console.WriteLine((b.Substring(0, b.IndexOf(".") + 3)));

            }


        }
    }
}
